package com.common.aspectj;

import com.common.anntation.SetNotNull;
import com.common.utils.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Set;

/**
 * @Author: zql
 * @Description: List类型参数校验器
 * @Data: 2021-07-16
 */
public class ListValidator implements ConstraintValidator<SetNotNull, Set> {

    @Override
    public boolean isValid(Set set, ConstraintValidatorContext constraintValidatorContext) {
        if (StringUtils.isEmpty(set)){
            return true;
        }

        for (Object o : set) {
            if (StringUtils.isNull(o)){
                return false;
            }
        }

        return true;
    }
}
